#pragma once

#include <sfif/sfif_sfif_types.h>

/* A structure that contains a geographical coordinate using the 
 * WGS 84 reference frame. 
 * latitude:  The latitude in degrees. Positive values indicate latitudes 
              north of the equator. Negative values indicate latitudes south 
              of the equator.
 * longitude: The longitude in degrees. Measurements are relative to the 
              zero meridian, with positive values extending east of the 
              meridian and negative values extending west of the meridian.
 */
typedef struct
{

  sfif_bool_t  available;          	     	/* if the data is available 1 otherwise 0 */
  sfif_int32_t timestamp;                      /* long millisec since 1970  GMT*/
  sfif_float_t latitude; 				/*in signed degrees           
                                                      precision 11.8f (ca cm)*/
  sfif_float_t longitude; 				/*in signed degrees relative to Greenich
                                                      precision 11.8f (ca.cm)*/
  sfif_float_t altitude;  				/*in m above sealevel     precision  7.2f*/
  sfif_float_t haccuracy; 				/*in meters               precision  8.2f*/
  sfif_float_t vaccuracy; 				/*in meters               precision  8.2f*/
  sfif_float_t speed;     				/*in meters/second,       precision  5.2f*/
  sfif_float_t course;				    /*Represents a direction that is measured 
                                      in degrees relative to grographical 
                                      north.  	              precision  5.2f*/
} iPhoneLocation;

typedef struct
{
  sfif_bool_t  available;	     	/* if the data is available 1 otherwise 0       */
  sfif_int32_t timestamp;             /*long in millisec since 1970  */
  sfif_float_t x; 		    /* The value reported by this property is 
                                   normalized to the range -128 to +128. 
						 * This value represents the x-axis deviation from the 
                           magnetic field lines being tracked by the device.*/
  sfif_float_t y;			    /* The value reported by this property is normalized 
                           to the range -128 to +128. 
						 * This value represents the y-axis deviation from the 
                           magnetic field lines being tracked by the device.*/
  sfif_float_t z;			    /* The value reported by this property is normalized 
                           to the range -128 to +128. 
						 * This value represents the z-axis deviation from the 
                           magnetic field lines being tracked by the device.*/
  sfif_float_t heading;	    /* The value in this property represents the heading 
                           relative to the geographic North Pole. 
						 * The value 0 means the device is pointed toward true 
                           north, 90 means it is pointed due east, 180 means 
                           it is pointed due south, and so on.
						 * A negative value indicates that the heading could 
                           not be determined. */
  sfif_int_t   headingOrientation; /* The location manager assumes that the top of 
                                the device in portrait mode represents due 
                                north (0 degrees) by default */
  sfif_float_t accuracy;		/* A positive value in this property represents the 
                           potential error between the value reported by the 
                           magneticHeading
						 * property and the actual direction of magnetic 
                           north. Thus, the lower the value of this property, 
                           the more accurate the heading. 
						 * A negative value means that the reported heading 
                           is invalid, which can occur when the device is 
                           uncalibrated or there is strong
						 * interference from local magnetic fields */
} iPhoneHeading;

typedef struct
{
  sfif_bool_t  available;	       /* if the data is available 1 otherwise 0        */
  sfif_int_t   focusmode;		   /*  FocusModeLocked                = 0,
   						    *  FocusModeAutoFocus             = 1,
   						    *  FocusModeContinuousAutoFocus   = 2           */
  sfif_int_t   adjustingfocus;   /* Indicates whether the device is 
                              currently adjusting its focus setting.        */
  sfif_int_t   pointOfInterestSupported; /* Indicates whether the device supports a 
                                      point of interest for focus. 
						      * if supported => x and y > 0 else x = y = 0  */
  sfif_float_t PointOfInterestX;			/* x coordinate of point precision 5.4f */
  sfif_float_t PointOfInterestY;			/* y coordinate of point precision 5.4f */
} iPhoneFocus;

typedef struct
{
  sfif_bool_t  available;	     	/* if the data is available 1 otherwise 0       */
  sfif_int_t   adjusting;         /* Indicates whether the device is currently 
                               adjusting its exposure setting               */
  sfif_int_t   mode;              /* ExposureModeLocked   = 0,
   						     * ExposureModeAutoExpose                = 1,
   						     * ExposureModeContinuousAutoExposure    = 2    */
  sfif_int_t   pointOfInterestSupported; /*Indicates whether the device supports a 
                                     point of interest for exposure. if the 
                                     support is not supported 0 otherwise 1.*/
  sfif_float_t PointOfInterestX;	/* x coordinate of point          precision 5.4f*/
  sfif_float_t PointOfInterestY;	/* y coordinate of point          precision 5.4f*/
} iPhoneExposure;


typedef struct{
  sfif_bool_t available;	     	/* if the data is available 1 otherwise 0      */
  sfif_int_t  mode;					/* WhiteBalanceModeLocked             = 0,
						     * WhiteBalanceModeAutoWhiteBalance   = 1,
   						     * WhiteBalanceModeContinuousAutoWhiteBalance =2*/
  sfif_int_t adjusting;		    /* Indicates whether the devise is currently 
                               adjusting the white balance. */
} iPhoneWhiteBalance;

typedef struct
{
  iPhoneFocus        focus;
  iPhoneExposure     exposure;
  iPhoneWhiteBalance whitebalance;
  sfif_int_t                flashoff;
} iPhonecameraDevice;


/* A G is a unit of gravitation force equal to that exerted by the earth_s 
       gravitational field (9.81 m/s^2) */
/*
	Herz	usage for
	10-20	Suitable for use in determining the vector representing the 
            current orientation of the device.
	30-60	Suitable for games and other applications that use the 
            accelerometers for real-time user input.
	70-100	Suitable for applications that need to detect high-frequency 
            motion. For example, you might use this interval to detect the 
            user hitting the device or shaking it very quickly.
*/
typedef struct 
{
  /*        |+y     -z (back)
        --------- /
        |   |   |/
        |   |  /|
        |   | / |
        |   |/_ |___+x
        |       |
        |------ |
        |   O   |
        --------
  */
  sfif_bool_t  available;	 /* if the data is available 1 otherwise 0 */
  sfif_float_t timeintervall;	 /* timeintervall for update device. presicion 1.2f */
  sfif_float_t x;              /* X-axis acceleration in gravitational force.
                                                              precision 2.2f*/
  sfif_float_t y;              /* Y-axis acceleration in gravitational force.
                                                              precision 2.2f*/
  sfif_float_t z;              /* Z-axis acceleration in gravitational force.
                                                              precision 2.2f*/
} iPhoneAcceleration;

/* represents a measurement of the device_s attitude at a point in time. 
   "Attitude refers to the orientation of a body relative to a given frame 
   of reference: */
/*
	Herz	usage for
	10-20	Suitable for use in determining the vector representing the 
            current orientation of the device.
	30-60	Suitable for games and other applications that use the 
            accelerometers for real-time user input.
	70-100	Suitable for applications that need to detect high-frequency 
            motion. For example, you might use this interval to detect 
            the user hitting the device or shaking it very quickly.
*/
typedef struct
{
  sfif_bool_t  available;    /* if the data is available 1 otherwise 0 */
  sfif_float_t timeintervall; /* timeintervall for update device.  presicion 1.2f */
  sfif_float_t pitch;         /* A pitch is a rotation around a lateral axis that 
                           passes through the device from side to side. 
                           [radian]                           precision 1.5f*/	
  sfif_float_t roll;          /* A roll is a rotation around a longitudinal axis 
                           that passes through the device from its top to 
                           bottom. [radian]                   precision 1.5f*/	
  sfif_float_t yaw;           /* A yaw is a rotation around an axis that runs 
                           vertically through the device. 
					     * It is perpendicular to the body of the device, 
					     * with its origin at the center of gravity and 
                           directed toward the bottom of the device. [radian]
                                                              precision 1.5f*/
} iPhoneAttitude;

/*gyroscope: Type of structures representing a measurement of rotation rate.*/
/*
	Herz	usage for
	10-20	Suitable for use in determining the vector representing the 
            current orientation of the device.
	30-60	Suitable for games and other applications that use the 
            accelerometers for real-time user input.
	70-100	Suitable for applications that need to detect high-frequency 
            motion. For example, you might use this interval to detect the 
            user hitting the device or shaking it very quickly.
*/
typedef struct
{
  sfif_bool_t  available;     /* if the data is available 1 otherwise 0          */
  sfif_float_t timeintervall;  /* timeintervall for update device. presicion 1.2f */
                /* The rotation rate as measured by the device_s gyroscope. */
                /* rawdata of device */
  sfif_float_t x; 			
  sfif_float_t y; 				
  sfif_float_t z; 				
} iPhoneRotateRate;
  
typedef struct
{
  iPhoneAcceleration acceleration;
  iPhoneRotateRate rotation;
  iPhoneAttitude attitude;
} iPhoneMotion;

typedef struct
{
  iPhoneLocation loc;
  iPhoneHeading head;
  iPhonecameraDevice video;
  iPhoneMotion motion;
} iPhoneDataset;

		
#define EMPTY_IPHONE_TIME {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \
                                                            0,0,0,0,0,0,0,0,0}
#define EMPTY_IPHONE_LOCATION {0,EMPTY_IPHONE_TIME,0,0,0,0,0,0,0}

#define EMPTY_IPHONE_HEADING {0,EMPTY_IPHONE_TIME,0,0,0,0,0,0}

#define EMPTY_IPHONE_FOCUS {0,0,0,0,0,0}
#define EMPTY_IPHONE_EXPOSURE {0,0,0,0,0,0}
#define EMPTY_IPHONE_WHITEBALANCE {0,0,0}
#define EMPTY_IPHONE_CAMERADEVICE {EMPTY_IPHONE_FOCUS,EMPTY_IPHONE_EXPOSURE,\
                                                   EMPTY_IPHONE_WHITEBALANCE,0}

#define EMPTY_IPHONE_ACCELERATION {0,0,0,0,0}
#define EMPTY_IPHONE_ROTATION {0,0,0,0,0}
#define EMPTY_IPHONE_ATTITUDE {0,0,0,0,0}
#define EMPTY_IPHONE_MOTION {EMPTY_IPHONE_ACCELERATION,EMPTY_IPHONE_ROTATION,\
                                                        EMPTY_IPHONE_ATTITUDE}

#define EMPTY_IPHONE_DATA {EMPTY_IPHONE_LOCATION,EMPTY_IPHONE_HEADING, \
                              EMPTY_IPHONE_CAMERADEVICE,EMPTY_IPHONE_MOTION}
